/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package enteties.article;

import enteties.person.Supplier;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Joris
 */
@Entity
@Table(name = "article")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Article.findAll", query = "SELECT a FROM Article a"),
    @NamedQuery(name = "Article.findById", query = "SELECT a FROM Article a WHERE a.id = :id"),
    @NamedQuery(name = "Article.findByArticleNumber", query = "SELECT a FROM Article a WHERE a.articleNumber = :articleNumber"),
    @NamedQuery(name = "Article.findLikeArticleNumber", query = "SELECT a FROM Article a WHERE a.articleNumber LIKE :articleNumber"),
    @NamedQuery(name = "Article.findByDescription", query = "SELECT a FROM Article a WHERE a.description = :description"),
    @NamedQuery(name = "Article.findLikeDescription", query = "SELECT a FROM Article a WHERE a.description LIKE :description"),
    @NamedQuery(name = "Article.findByUpdated", query = "SELECT a FROM Article a WHERE a.updated = :updated"),
    @NamedQuery(name = "Article.findByCreated", query = "SELECT a FROM Article a WHERE a.created = :created"),
    @NamedQuery(name = "Article.findBySupplierAndNumber", query = "SELECT a FROM Article a WHERE a.supplierId = :supplierId AND a.articleNumber = :articelNumber")})
public class Article implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "articleNumber")
    private String articleNumber;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "description")
    private String description;
    @Column(name = "updated")
    @Temporal(TemporalType.TIMESTAMP)
    private Date updated;
    @Column(name = "created")
    @Temporal(TemporalType.TIMESTAMP)
    private Date created;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Model> modelCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Price> priceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Stock> stockCollection;
    @JoinColumn(name = "Group_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Group1 groupid;
    @JoinColumn(name = "Supplier_id", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Supplier supplierId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Image> imageCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Eancode> eancodeCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "articleid")
    private Collection<Size1> size1Collection;

    public Article() {
    }

    public Article(Integer id) {
        this.id = id;
    }

    public Article(Integer id, String articleNumber, String description) {
        this.id = id;
        this.articleNumber = articleNumber;
        this.description = description;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getArticleNumber() {
        return articleNumber;
    }

    public void setArticleNumber(String articleNumber) {
        this.articleNumber = articleNumber;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    @XmlTransient
    public Collection<Model> getModelCollection() {
        return modelCollection;
    }

    public void setModelCollection(Collection<Model> modelCollection) {
        this.modelCollection = modelCollection;
    }

    @XmlTransient
    public Collection<Price> getPriceCollection() {
        return priceCollection;
    }

    public void setPriceCollection(Collection<Price> priceCollection) {
        this.priceCollection = priceCollection;
    }

    @XmlTransient
    public Collection<Stock> getStockCollection() {
        return stockCollection;
    }

    public void setStockCollection(Collection<Stock> stockCollection) {
        this.stockCollection = stockCollection;
    }

    public Group1 getGroupid() {
        return groupid;
    }

    public void setGroupid(Group1 groupid) {
        this.groupid = groupid;
    }
    
    public Supplier getSupplier() {
        return supplierId;
    }

    public void setSupplier(Supplier supplierId) {
        this.supplierId = supplierId;
    }

    @XmlTransient
    public Collection<Image> getImageCollection() {
        return imageCollection;
    }

    public void setImageCollection(Collection<Image> imageCollection) {
        this.imageCollection = imageCollection;
    }

    @XmlTransient
    public Collection<Eancode> getEancodeCollection() {
        return eancodeCollection;
    }

    public void setEancodeCollection(Collection<Eancode> eancodeCollection) {
        this.eancodeCollection = eancodeCollection;
    }

    @XmlTransient
    public Collection<Size1> getSize1Collection() {
        return size1Collection;
    }

    public void setSize1Collection(Collection<Size1> size1Collection) {
        this.size1Collection = size1Collection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Article)) {
            return false;
        }
        Article other = (Article) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "enteties.article.Article[ id=" + id + " ]";
    }
    
}
